package com.tian.controller.management;

import com.tian.common.CommonResult;
import com.tian.dto.*;
import com.tian.service.ChargeStationService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * {@code @description:} 站点信息
 *
 * @author tianwc 公众号：Java后端技术全栈
 * 在线刷题 1200+java面试题和1000+篇技术文章：<a href="https://woaijava.cc/">博客地址</a>
 * {@code @date:} 2024/1/18 18:51
 * {@code @version:} 1.0
 */
@RestController
@RequestMapping("/management/station")
public class ChargeStationController {
    @Resource
    private ChargeStationService chargeStationService;

    @GetMapping("/test/{message}")
    public String test(@PathVariable("message") String message) {
        return chargeStationService.test(message);
    }

    @GetMapping("/{id}")
    public CommonResult<StationRespDto> findById(@PathVariable("id") Integer id) {
        return chargeStationService.findById(id);
    }

    /**
     * 添加站点信息
     */
    @PostMapping("/add")
    public CommonResult<Boolean> add(@RequestBody StationDto stationDto) {
        return chargeStationService.add(stationDto);
    }

    @PostMapping("/page")
    public CommonResult<StationQueryPageRespDto> listByPage(@RequestBody ChargeStationQueryPageReqDto chargeStationQueryPageReqDto) {
        return chargeStationService.listByPage(chargeStationQueryPageReqDto,false);
    }

    @PostMapping("/update")
    public CommonResult<Boolean> update(@RequestBody StationDto stationDto) {
        return chargeStationService.update(stationDto);
    }
    @PostMapping("/update/detail")
    public CommonResult<Boolean> updateDetail(@RequestBody StationDto stationDto) {
        return chargeStationService.updateDetail(stationDto);
    }
    @PostMapping("/start")
    public CommonResult<Boolean> start(@RequestBody StationStopDto stationStopDto) {
        return chargeStationService.start(stationStopDto.getId());
    }
    @PostMapping("/stop")
    public CommonResult<Boolean> stop(@RequestBody StationStopDto stationStopDto) {
        return chargeStationService.stop(stationStopDto.getId());
    }
    @PostMapping("/bind")
    public CommonResult<Boolean> bind(@RequestBody StationDto stationDto) {
        return chargeStationService.bind(stationDto);
    }

    @GetMapping("/count/index")
    public CommonResult<StationCount4ManagementRespDto> count4ManagementIndex(){
        return chargeStationService.count4ManagementIndex();
    }
}
